home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 2.iso / dist / fw_libmikmod.idb / usr / freeware / info / mikmod.info-1.z / mikmod.info-1
Text File  |  2000-06-09  |  49KB  |  1,321 lines

  1. This is mikmod.info, produced by Makeinfo version 3.12f from
  2. mikmod.texi.
  3.  
  4.    Copyright (C) 1998, 1999, 2000 Miodrag Vallat and others -- see file
  5. AUTHORS for complete list.
  6.  
  7.    This library is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU Library General Public License as
  9. published by the Free Software Foundation; either version 2 of the
  10. License, or (at your option) any later version.
  11.  
  12.    This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. Library General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU Library General Public
  18. License along with this library; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  20. USA.
  21.  
  22. INFO-DIR-SECTION Programming
  23. START-INFO-DIR-ENTRY
  24. * MikMod: (mikmod).            MikMod Sound Library.
  25. END-INFO-DIR-ENTRY
  26.  
  27. 
  28. File: mikmod.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  29.  
  30. MikMod Sound Library
  31. ********************
  32.  
  33. This manual documents the MikMod Sound Library, version 3.1.9.
  34.  
  35. * Menu:
  36.  
  37. * Introduction::          What is MikMod ?
  38. * Tutorial::              Your first steps with MikMod.
  39. * Using the Library::     A thematic presentation of the library.
  40. * Library Reference::     Detailed description of the functions and variables.
  41. * Index::
  42.  
  43. 
  44. File: mikmod.info,  Node: Introduction,  Next: Tutorial,  Prev: Top,  Up: Top
  45.  
  46. Introduction
  47. ************
  48.  
  49.    The MikMod sound library is an excellent way for a programmer to add
  50. music and sound effects to an application. It is a powerful and
  51. flexible library, with a simple and easy-to-learn API.
  52.  
  53.    Besides, the library is very portable and runs under a lot of
  54. Unices, as well as under OS/2, MacOS and Windows. Third party
  55. individuals also maintain ports on other systems, including MS-DOS, and
  56. BeOS.
  57.  
  58.    MikMod is able to play a wide range of module formats, as well as
  59. digital sound files. It can take advantage of particular features of
  60. your system, such as sound redirection over the network. And due to its
  61. modular nature, the library can be extended to support more sound or
  62. module formats, as well as new hardware or other sound output
  63. capabilities, as they appear.
  64.  
  65. 
  66. File: mikmod.info,  Node: Tutorial,  Next: Using the Library,  Prev: Introduction,  Up: Top
  67.  
  68. Tutorial
  69. ********
  70.  
  71.    This chapter will describe how to quickly incorporate MikMod's power
  72. into your programs. It doesn't cover everything, but that's a start and
  73. I hope it will help you understand the library philosophy.
  74.  
  75.    If you have a real tutorial to put here, you're welcome ! Please
  76. send it to me....
  77.  
  78. * Menu:
  79.  
  80. * MikMod Concepts::         A few things you'll need to know.
  81. * A Skeleton Program::      The shortest MikMod program.
  82. * Playing Modules::         How to create a simple module player.
  83. * Playing Sound Effects::   How to play simple sound effects.
  84. * More Sound Effects::      How to play more complex sound effects.
  85.  
  86. 
  87. File: mikmod.info,  Node: MikMod Concepts,  Next: A Skeleton Program,  Prev: Tutorial,  Up: Tutorial
  88.  
  89. MikMod Concepts
  90. ===============
  91.  
  92.    MikMod's sound output is composed of several sound _voices_ which are
  93. mixed, either in software or in hardware, depending of your hardware
  94. configuration. Simple sounds, like sound effects, use only one voice,
  95. whereas sound modules, which are complex arrangements of sound effects,
  96. use several voices.
  97.  
  98.    MikMod's functions operate either globally, or at the voice level.
  99. Differences in the handling of sound effects and modules are kept
  100. minimal, at least for the programmer.
  101.  
  102.    The sound playback is done by a _sound driver_. MikMod provides
  103. several sound drivers: different hardware drivers, and some software
  104. drivers to redirect sound in a file, or over the network. You can even
  105. add your own driver, register it to make it known by the library, and
  106. select it (this is exactly what the module plugin of xmms does).
  107.  
  108. 
  109. File: mikmod.info,  Node: A Skeleton Program,  Next: Playing Modules,  Prev: MikMod Concepts,  Up: Tutorial
  110.  
  111. A Skeleton Program
  112. ==================
  113.  
  114.    To use MikMod in your program, there are a few steps required:
  115.  
  116.    * Include `mikmod.h' in your program.
  117.  
  118.    * Register the MikMod drivers you need.
  119.  
  120.    * Initialize the library with MikMod_Init() before using any other
  121.      MikMod function.
  122.  
  123.    * Give up resources with MikMod_Exit() at the end of your program,
  124.      or before when MikMod is not needed anymore.
  125.  
  126.    * Link your application with the MikMod sound library.
  127.  
  128.    Here's a program which meets all those conditions:
  129.  
  130.      /* MikMod Sound Library example program: a skeleton */
  131.      
  132.      #include <mikmod.h>
  133.      
  134.      main()
  135.      {
  136.          /* register all the drivers */
  137.          MikMod_RegisterAllDrivers();
  138.      
  139.          /* initialize the library */
  140.          MikMod_Init("");
  141.      
  142.          /* we could play some sound here... */
  143.      
  144.          /* give up */
  145.          MikMod_Exit();
  146.      }
  147.  
  148.    This program would be compiled with the following command line: `cc
  149. -o example example.c `libmikmod-config --cflags` `libmikmod-config
  150. --libs`'
  151.  
  152.    Although this programs produces no useful result, many things happen
  153. when you run it. The call to `MikMod_RegisterAllDrivers' registers all
  154. the drivers embedded in the MikMod library. Then, `MikMod_Init' chooses
  155. the more adequate driver and initializes it. The program is now ready
  156. to produce sound.  When sound is not needed any more, `MikMod_Exit' is
  157. used to relinquish memory and let other programs have access to the
  158. sound hardware.
  159.  
  160. 
  161. File: mikmod.info,  Node: Playing Modules,  Next: Playing Sound Effects,  Prev: A Skeleton Program,  Up: Tutorial
  162.  
  163. Playing Modules
  164. ===============
  165.  
  166.    Our program is not really useful if it doesn't produce sound. Let's
  167. suppose you've got this good old module, "Beyond music", in the file
  168. `beyond music.mod'. How about playing it ?
  169.  
  170.    To do this, we'll use the following code:
  171.  
  172.      /* MikMod Sound Library example program: a simple module player */
  173.      
  174.      #include <unistd.h>
  175.      #include <mikmod.h>
  176.      
  177.      main()
  178.      {
  179.          MODULE *module;
  180.      
  181.          /* register all the drivers */
  182.          MikMod_RegisterAllDrivers();
  183.      
  184.          /* register all the module loaders */
  185.          MikMod_RegisterAllLoaders();
  186.      
  187.          /* initialize the library */
  188.          md_mode |= DMODE_SOFT_MUSIC;
  189.          if (MikMod_Init("")) {
  190.              fprintf(stderr, "Could not initialize sound, reason: %s\n",
  191.                      MikMod_strerror(MikMod_errno));
  192.              return;
  193.          }
  194.      
  195.          /* load module */
  196.          module = Player_Load("beyond music.mod", 64, 0);
  197.          if (module) {
  198.              /* start module */
  199.              Player_Start(module);
  200.      
  201.              while (Player_Active()) {
  202.                  /* we're playing */
  203.                  usleep(10000);
  204.                  MikMod_Update();
  205.              }
  206.      
  207.              Player_Stop();
  208.              Player_Free(module);
  209.          } else
  210.              fprintf(stderr, "Could not load module, reason: %s\n",
  211.                      MikMod_strerror(MikMod_errno));
  212.      
  213.          /* give up */
  214.          MikMod_Exit();
  215.      }
  216.  
  217.    What's new here ? First, we've not only registered MikMod's device
  218. driver, but also the module loaders. MikMod comes with a large choice
  219. of module loaders, each one for a different module type. Since _every_
  220. loader is called to determine the type of the module when we try to
  221. load them, you may want to register only a few of them to save time. In
  222. our case, we don't matter, so we happily register every module loader.
  223.  
  224.    Then, there's an extra line before calling `MikMod_Init'. We change
  225. the value of MikMod's variable `md_mode' to tell the library that we
  226. want the module to be processed by the software. If you're the happy
  227. owner of a GUS-type card, you could use the specific hardware driver
  228. for this card, but in this case you should not set the
  229. `DMODE_SOFT_MUSIC' flag.
  230.  
  231.    We'll ensure that `MikMod_Init' was successful. Note that, in case of
  232. error, MikMod provides the variable `MikMod_errno', an equivalent of
  233. the C library `errno' for MikMod errors, and the function
  234. `MikMod_strerror', an equivalent to `strerror'.
  235.  
  236.    Now onto serious business ! The module is loaded with the
  237. `Player_Load' function, which takes the name of the module file, and
  238. the number of voices afforded to the module. In this case, the module
  239. has only 4 channels, so 4 voices, but complex Impulse Tracker modules
  240. can have a lot of voices (as they can have as many as 256 virtual
  241. channels with so-called "new note actions").  Since empty voices don't
  242. cost time to be processed, it is safe to use a big value, such as 64 or
  243. 128. The third parameter is the "curiosity" of the loader: if nonzero,
  244. the loader will search for hidden parts in the module.  However, only a
  245. few module formats can embed hidden or non played parts, so we'll use 0
  246. here.
  247.  
  248.    Now that the module is ready to play, let's play it. We inform the
  249. player that the current module is `module' with `Player_Start'.
  250. Playback starts, but we have to update it on a regular basis. So
  251. there's a loop on the result of the `Player_Active' function, which
  252. will tell us if the module has finished. To update the sound, we simply
  253. call `MikMod_Update'.
  254.  
  255.    After the module has finished, we tell the player its job is done
  256. with `Player_Stop', and we free the module with `Player_Free'.
  257.  
  258. 
  259. File: mikmod.info,  Node: Playing Sound Effects,  Next: More Sound Effects,  Prev: Playing Modules,  Up: Tutorial
  260.  
  261. Playing Sound Effects
  262. =====================
  263.  
  264.    MikMod is not limited to playing modules, it can also play sound
  265. effects, that is, module samples. It's a bit more complex than playing
  266. a module, because the module player does a lot of things for us, but
  267. here we'll get more control over what is actually played by the
  268. program. Let's look at an example:
  269.  
  270.      /* MikMod Sound Library example program: sound effects */
  271.      
  272.      #include <unistd.h>
  273.      #include <mikmod.h>
  274.      
  275.      main()
  276.      {
  277.          int i;
  278.          /* sound effects */
  279.          SAMPLE *sfx1, *sfx2;
  280.          /* voices */
  281.          int v1, v2;
  282.      
  283.          /* register all the drivers */
  284.          MikMod_RegisterAllDrivers();
  285.      
  286.          /* initialize the library */
  287.          md_mode |= DMODE_SOFT_SNDFX;
  288.          if (MikMod_Init("")) {
  289.              fprintf(stderr, "Could not initialize sound, reason: %s\n",
  290.                      MikMod_strerror(MikMod_errno));
  291.              return;
  292.          }
  293.      
  294.          /* load samples */
  295.          sfx1 = Sample_Load("first.wav");
  296.          if (!sfx1) {
  297.              MikMod_Exit();
  298.              fprintf(stderr, "Could not load the first sound, reason: %s\n",
  299.                      MikMod_strerror(MikMod_errno));
  300.              return;
  301.          }
  302.          sfx2 = Sample_Load("second.wav");
  303.          if (!sfx2) {
  304.              Sample_Free(sfx1);
  305.              MikMod_Exit();
  306.              fprintf(stderr, "Could not load the second sound, reason: %s\n",
  307.                      MikMod_strerror(MikMod_errno));
  308.              return;
  309.          }
  310.      
  311.          /* reserve 2 voices for sound effects */
  312.          MikMod_SetNumVoices(-1, 2);
  313.      
  314.          /* get ready to play */
  315.          MikMod_EnableOutput();
  316.      
  317.          /* play first sample */
  318.          v1 = Sample_Play(sfx1, 0, 0);
  319.          for(i = 0; i < 5; i++) {
  320.              MikMod_Update();
  321.              usleep(100000);
  322.          }
  323.      
  324.          /* half a second later, play second sample */
  325.          v2 = Sample_Play(sfx2, 0, 0);
  326.          do {
  327.              MikMod_Update();
  328.              usleep(100000);
  329.          } while (!Voice_Stopped(v2));
  330.      
  331.          MikMod_DisableOutput();
  332.      
  333.          Sample_Free(sfx2);
  334.          Sample_Free(sfx1);
  335.      
  336.          MikMod_Exit();
  337.      }
  338.  
  339.    As in the previous example, we begin by registering the sound
  340. drivers and initializing the library. We also ask for software mixing
  341. by modifying the variable `md_mode'.
  342.  
  343.    It's time to load our files, with the `Sample_Load' function. Don't
  344. forget to test the return value -- it looks ugly here on such a small
  345. example, but it's a good practice....
  346.  
  347.    Since we want to play two samples, we have to use at least two
  348. voices for this, so we reserve them with a `MikMod_SetNumVoices' call.
  349. The first parameter sets the number of module voices, and the second
  350. parameter the number of sound effect voices. We don't want to set the
  351. number of module voices here (it's part of the module player's duty),
  352. so we use the value `-1' to keep the current value, and we reserve two
  353. sound effect voices.
  354.  
  355.    Now we're ready to play, so we call `MikMod_EnableOutput' to make the
  356. driver ready. Sound effects are played by the `Sample_Play' function.
  357. You just have to specify which sample you want to play, the offset from
  358. which you want to start, and the playback flags. More on this later.
  359. The function returns the number of the voice associated to the sample.
  360.  
  361.    We play the first sample for half a second, then we start to play
  362. the second sample. Since we've reserved two channels, both samples play
  363. simultaneously. We use the `Voice_Stopped' function to stop the
  364. playback: it returns the current status of the voice argument, which is
  365. zero when the sample plays and nonzero when it has finished. So the
  366. `do' loop will stop exactly when the second sample is finished,
  367. regardless of the length of the first sample.
  368.  
  369.    To finish, we get rid of the samples with `Sample_Free'.
  370.  
  371. 
  372. File: mikmod.info,  Node: More Sound Effects,  Prev: Playing Sound Effects,  Up: Tutorial
  373.  
  374. More Sound Effects
  375. ==================
  376.  
  377.    Sound effects have some attributes that can be affected to control
  378. the playback.  These are speed, panning, and volume. Given a voice
  379. number, you can affect these attributes with the `Voice_SetFrequency',
  380. `Voice_SetPanning' and `Voice_SetVolume' functions.
  381.  
  382.    In the previous example, we'll replace the actual sound code,
  383. located between the calls to `MikMod_EnableOutput' and
  384. `MikMod_DisableOutput', with the following code:
  385.  
  386.          Sample_Play(sfx1, 0, 0);
  387.          for(i = 0; i < 5; i++) {
  388.              MikMod_Update();
  389.              usleep(100000);
  390.          }
  391.          v2 = Sample_Play(sfx2, 0, SFX_CRITICAL);
  392.          i = 0;
  393.          do {
  394.              MikMod_Update();
  395.              usleep(100000);
  396.              v1 = Sample_Play(sfx1, 0, 0);
  397.              Voice_SetVolume(v1, 160);
  398.              Voice_SetFrequency(v1, (sfx1->speed * (100 + i)) / 100);
  399.              Voice_SetPanning(v2, (i++ & 1) ? PAN_LEFT : PAN_RIGHT);
  400.          } while (!Voice_Stopped(v2));
  401.  
  402.    The first thing you'll notice, is the `SFX_CRITICAL' flag used to
  403. play the second sample. Since the `do' loop will add another sample
  404. every 100 milliseconds, and we reserved only two voices, the oldest
  405. voice will be cut each time this is necessary. Doing this would cut the
  406. second sample in the second iteration of the loop. However, since we
  407. flagged this sound as "critical", it won't be cut until it is finished
  408. or we stop it with a `Voice_Stop' call. So the second sample will play
  409. fine, whereas the first sample will be stopped every loop iteration.
  410.  
  411.    Then, we choose to play the first sample a bit lower, with
  412. `Voice_SetVolume'. Volume voices range from 0 (silence) to 256. In this
  413. case we play the sample at 160. To make the sound look weird, we also
  414. change its frequency with `Voice_SetFrequency'. The computation in the
  415. example code makes the frequency more and more high (starting from the
  416. sample frequency and then increasing from 1% each iteration).
  417.  
  418.    And to demonstrate the `Voice_SetPanning' function, we change the
  419. panning of the second sample at each iteration from the left to the
  420. right. The argument can be one of the standard panning `PAN_LEFT',
  421. `PAN_RIGHT', `PAN_CENTER' and `PAN_SURROUND'(1), or a numeric value
  422. between 0 (`PAN_LEFT') and 255 (`PAN_RIGHT').
  423.  
  424.    ---------- Footnotes ----------
  425.  
  426.    (1) `PAN_SURROUND' will be mapped to `PAN_CENTER' if the library is
  427. initialized without surround sound, that is, if the variable `md_mode'
  428. doesn't have the bit `DMODE_SURROUND' set.
  429.  
  430. 
  431. File: mikmod.info,  Node: Using the Library,  Next: Library Reference,  Prev: Tutorial,  Up: Top
  432.  
  433. Using the Library
  434. *****************
  435.  
  436.    This chapter describes the various parts of the library and their
  437. uses.
  438.  
  439. * Menu:
  440.  
  441. * Library Version::
  442. * Type Definitions::
  443. * Error Handling::
  444. * Library Initialization::
  445. * Samples and Voice Control::
  446. * Modules and Player Control::
  447. * Loading Data from Memory::
  448.  
  449. 
  450. File: mikmod.info,  Node: Library Version,  Next: Type Definitions,  Prev: Using the Library,  Up: Using the Library
  451.  
  452. Library Version
  453. ===============
  454.  
  455.    If your program is dynamically linked with the MikMod library, you
  456. should check which version of the library you're working with.  To do
  457. this, the library defines a few constants and a function to help you
  458. determine if the current library is adequate for your needs or if it
  459. has to be upgraded.
  460.  
  461.    When your program includes `mikmod.h', the following constants are
  462. defined:
  463.    * `LIBMIKMOD_VERSION_MAJOR' is equal to the major version number of
  464.      the library.
  465.  
  466.    * `LIBMIKMOD_VERSION_MINOR' is equal to the minor version number of
  467.      the library.
  468.  
  469.    * `LIBMIKMOD_REVISION' is equal to the revision number of the
  470.      library.
  471.  
  472.    * `LIBMIKMOD_VERSION' is the sum of `LIBMIKMOD_VERSION_MAJOR'
  473.      shifted 16 times, `LIBMIKMOD_VERSION_MINOR' shifted 8 times, and
  474.      `LIBMIKMOD_REVISION'.
  475.  
  476.    So your program can tell with which version of the library it has
  477. been compiled this way:
  478.      printf("Compiled with MikMod Sound Library version %ld.%ld.%ld\n",
  479.             LIBMIKMOD_VERSION_MAJOR,
  480.             LIBMIKMOD_VERSION_MINOR,
  481.             LIBMIKMOD_REVISION);
  482.  
  483.    The library defines the function `MikMod_GetVersion' which returns
  484. the value of LIBMIKMOD_VERSION for the library. If this value is
  485. greater than or equal to the value of LIBMIKMOD_VERSION for your
  486. program, your program will work; otherwise, you'll have to inform the
  487. user that he has to upgrade the library:
  488.  
  489.      {
  490.          long engineversion = MikMod_GetVersion();
  491.      
  492.          if (engineversion < LIBMIKMOD_VERSION) {
  493.              printf("MikMod library version (%ld.%ld.%ld) is too old.\n",
  494.                     (engineversion >> 16) & 255,
  495.                     (engineversion >> 8) & 255,
  496.                     (engineversion) & 255);
  497.              printf("This programs requires at least version %ld.%ld.%ld\n",
  498.                     LIBMIKMOD_VERSION_MAJOR,
  499.                     LIBMIKMOD_VERSION_MINOR,
  500.                     LIBMIKMOD_REVISION);
  501.              puts("Please upgrade your MikMod library.");
  502.              exit(1);
  503.          }
  504.      }
  505.  
  506. 
  507. File: mikmod.info,  Node: Type Definitions,  Next: Error Handling,  Prev: Library Version,  Up: Using the Library
  508.  
  509. Type Definitions
  510. ================
  511.  
  512.    MikMod defines several data types to deal with modules and sample
  513. data.  These types have the same memory size on every platform MikMod
  514. has been ported to.
  515.  
  516.    These types are:
  517.    * `CHAR' is a printable character. For now it is the same as the
  518.      `char' type, but in the future it may be wide char (Unicode) on
  519.      some platforms.
  520.  
  521.    * `SBYTE' is a signed 8 bit number (can range from -128 to 127).
  522.  
  523.    * `UBYTE' is an unsigned 8 bit number (can range from 0 to 255).
  524.  
  525.    * `SWORD' is a signed 16 bit number (can range from -32768 to 32767).
  526.  
  527.    * `UWORD' is an unsigned 16 bit number (can range from 0 to 65535).
  528.  
  529.    * `SLONG' is a signed 32 bit number (can range from -2.147.483.648 to
  530.      2.147.483.647).
  531.  
  532.    * `ULONG' is an unsigned 32 bit number (can range from 0 to
  533.      4.294.967.296).
  534.  
  535.    * `BOOL' is a boolean value. A value of 0 means false, any other
  536.      value means true.
  537.  
  538. 
  539. File: mikmod.info,  Node: Error Handling,  Next: Library Initialization,  Prev: Type Definitions,  Up: Using the Library
  540.  
  541. Error Handling
  542. ==============
  543.  
  544.    Although MikMod does its best to do its work, there are times where
  545. it can't.  For example, if you're trying to play a corrupted file,
  546. well, it can't.
  547.  
  548.    A lot of MikMod functions return pointers or `BOOL' values. If the
  549. pointer is `NULL' or the `BOOL' is 0 (false), an error has occurred.
  550.  
  551.    MikMod errors are returned in the variable `MikMod_errno'. Each
  552. possible error has a symbolic error code, beginning with `MMERR_'. For
  553. example, if MikMod can't open a file, `MikMod_errno' will receive the
  554. value `MMERR_OPENING_FILE'.
  555.  
  556.    You can get an appropriate error message to display from the function
  557. `MikMod_strerror'.
  558.  
  559.    There is a second error variable named `MikMod_critical'. As its name
  560. suggests, it is only set if the error lets the library in an unstable
  561. state.  This variable can only be set by the functions `MikMod_Init',
  562. `MikMod_SetNumVoices' and `MikMod_EnableOutput'. If one of these
  563. functions return an error and `MikMod_critical' is set, the library is
  564. left in the uninitialized state (i.e. it was not initialized, or
  565. `MikMod_Exit' was called).
  566.  
  567.    If you prefer, you can use a callback function to get notified of
  568. errors. This function must be prototyped as `void MyFunction(void)'.
  569. Then, call `MikMod_RegisterHandler' with your function as argument to
  570. have it notified when an error occurs. There can only be one callback
  571. function registered, but `MikMod_RegisterHandler' will return you the
  572. previous handler, so you can chain handlers if you want to.
  573.  
  574. 
  575. File: mikmod.info,  Node: Library Initialization,  Next: Samples and Voice Control,  Prev: Error Handling,  Up: Using the Library
  576.  
  577. Library Initialization and Core Functions
  578. =========================================
  579.  
  580.    To initialize the library, you must register some sound drivers
  581. first. You can either register all the drivers embedded in the library
  582. for your platform with `MikMod_RegisterAllDrivers', or register only
  583. some of them with `MikMod_RegisterDriver'. If you choose to register
  584. the drivers manually, you must be careful in their order, since
  585. `MikMod_Init' will try them in the order you registered them. The
  586. `MikMod_RegisterAllDrivers' function registers the network drivers
  587. first (for playing sound over the network), then the hardware drivers,
  588. then the disk writers, and in last resort, the nosound driver.
  589. Registering the nosound driver first would not be a very good idea....
  590.  
  591.    You can get some printable information regarding the registered
  592. drivers with `MikMod_InfoDriver'; don't forget to call `free' on the
  593. returned string when you don't need it anymore.
  594.  
  595.    After you've registered your drivers, you can initialize the sound
  596. playback with `MikMod_Init', passing specific information to the driver
  597. if necessary. If you set the variable `md_device' to zero, which is its
  598. default value, the driver will be autodetected, that is, the first
  599. driver in the list that is available on the system will be used;
  600. otherwise only the driver whose order in the list of the registered
  601. drivers is equal to `md_device' will be tried.  If your playback
  602. settings, in the variables `md_mixfreq' and `md_mode', are not
  603. supported by the device, `MikMod_Init' will fail.
  604.  
  605.    You can then choose the number of voices you need with
  606. `MikMod_SetNumVoices', and activate the playback with
  607. `MikMod_EnableOutput'.
  608.  
  609.    Don't forget to call `MikMod_Update' as often as possible to process
  610. the sound mixing. If necessary, fork a dedicated process to do this, or
  611. if the library is thread-safe on your system, use a dedicated thread.
  612.  
  613.    If you want to change playback settings, most of them can't be
  614. changed on the fly. You'll need to stop the playback and reinitialize
  615. the driver. Use `MikMod_Active' to check if there is still sound
  616. playing; in this case, call `MikMod_DisableOutput' to end playback.
  617. Then, change your settings and call `MikMod_Reset'. You're now ready to
  618. select your number of voices and restart playback.
  619.  
  620.    When your program ends, don't forget to stop playback and call
  621. `MikMod_Exit' to leave the sound hardware in a coherent state.
  622.  
  623.    On systems that have pthreads, libmikmod is thread-safe(1). You can
  624. check this in your programs with the `MikMod_InitThreads' function. If
  625. this function returns 1, the library is thread-safe.
  626.  
  627.    The main benefit of thread-safety is that `MikMod_Update' can be
  628. called from a separate thread, which often makes application design
  629. easier. However, several libmikmod global variables are accessible from
  630. all your threads, so when more than one thread need to access libmikmod
  631. variables, you'll have to protect these access with the `MikMod_Lock'
  632. and `MikMod_Unlock' functions. If libmikmod is not thread-safe, these
  633. functions are no-ops.
  634.  
  635.    ---------- Footnotes ----------
  636.  
  637.    (1) Unless you explicitely choose to create a non thread-safe
  638. version of libmikmod at compile-time.
  639.  
  640. 
  641. File: mikmod.info,  Node: Samples and Voice Control,  Next: Modules and Player Control,  Prev: Library Initialization,  Up: Using the Library
  642.  
  643. Samples and Voice Control
  644. =========================
  645.  
  646.    Currently, MikMod only supports uncompressed mono WAV files as
  647. samples. You can load a sample by calling `Sample_Load' with a
  648. filename, or by calling `Sample_LoadFP' with an open `FILE*' pointer.
  649. These functions return a pointer to a `SAMPLE' structure, or `NULL' in
  650. case of error.
  651.  
  652.    The `SAMPLE' structure has a few interesting fields:
  653.    - `speed' contains the default frequency of the sample.
  654.  
  655.    - `volume' contains the default volume of the sample, ranging from 0
  656.      (silence) to 64.
  657.  
  658.    - `panning' contains the default panning position of the sample.
  659.  
  660.    Altering one of those fields will affect all voices currently
  661. playing the sample. You can achieve the same result on a single voice
  662. with the functions `Voice_SetFrequency', `Voice_SetVolume' and
  663. `Voice_SetPanning'.  Since the same sample can be played with different
  664. frequency, volume and panning parameters on each voice, you can get
  665. voice specific information with `Voice_GetFrequency', `Voice_GetVolume'
  666. and `Voice_GetPanning'.
  667.  
  668.    You can also make your sample loop by setting the fields `loopstart'
  669. and `loopend' and or'ing `flags' with `SF_LOOP'. To compute your loop
  670. values, the field `length' will be useful. However, you must know that
  671. all the sample length are expressed in samples, i.e. 8 bits for an 8
  672. bit sample, and 16 bit for a 16 bit sample... Test `flags' for the value
  673. `SF_16BITS' to know this.
  674.  
  675.    Speaking of flags, if you're curious and want to know the original
  676. format of the sample on disk (since libmikmod does some work on the
  677. sample data internally), refer to the `inflags' field.
  678.  
  679.    If the common forward loop isn't enough, you can play with some
  680. other flags: `SF_BIDI' will make your sample loop "ping pong" (back and
  681. forth), and `SF_REVERSE' will make it play backwards.
  682.  
  683.    To play your sample, use the `Sample_Play' function. This function
  684. will return a voice number which enable you to use the `Voice_xx'
  685. functions.
  686.  
  687.    The sample will play until another sample takes over its voice (when
  688. you play more samples than you reserved sound effect voices), unless it
  689. has been flagged as `SFX_CRITICAL'. You can force it to stop with
  690. `Voice_Stop', or you can force another sample to take over this voice
  691. with `Voice_Play'; however `Voice_Play' doesn't let you flag the new
  692. sample as critical.
  693.  
  694.    Non looping samples will free their voice channel as soon as they
  695. are finished; you can know the current playback position of your sample
  696. with `Voice_GetPosition'. If it is zero, either the sample has finished
  697. playing or it is just beginning; use `Voice_Stopped' to know.
  698.  
  699.    When you don't need a sample anymore, don't forget to free its
  700. memory with `Sample_Free'.
  701.  
  702. 
  703. File: mikmod.info,  Node: Modules and Player Control,  Next: Loading Data from Memory,  Prev: Samples and Voice Control,  Up: Using the Library
  704.  
  705. Modules and Player Control
  706. ==========================
  707.  
  708.    As for the sound drivers, you have to register the module loaders
  709. you want to use for MikMod to be able to load modules. You can either
  710. register all the module loaders with `MikMod_RegisterAllLoaders', or
  711. only a few of them with `MikMod_RegisterLoader'. Be careful if you
  712. choose this solution, as the 15 instrument MOD loader has to be
  713. registered last, since loaders are called in the order they were
  714. register to identify modules, and the detection of this format is not
  715. fully reliable, so other modules might be mistaken as 15 instrument MOD
  716. files.
  717.  
  718.    You can get some printable information regarding the registered
  719. loaders with `MikMod_InfoLoader'; don't forget to call `free' on the
  720. returned string when you don't need it anymore.
  721.  
  722.    Note that, contrary to the sound drivers, you can register module
  723. loaders at any time, it doesn't matter.
  724.  
  725.    For playlists, you might be interested in knowing the module title
  726. first, and `Player_LoadTitle' will give you this information. Don't
  727. forget to `free' the returned text when you don't need it anymore.
  728.  
  729.    You can load a module either with `Player_Load' and the name of the
  730. module, or with `Player_LoadFP' and an open `FILE*' pointer. These
  731. functions also expect a maximal number of voices, and a curiosity flag.
  732. Unless you have excellent reasons not to do so, choose a big limit,
  733. such as 64 or even 128 for complex Impulse Tracker modules. Both
  734. functions return a pointer to an `MODULE' structure, or `NULL' if an
  735. error occurs.
  736.  
  737.    You'll find some useful information in this structure:
  738.    - `numchn' contains the number of module "real" channels.
  739.  
  740.    - `numvoices' contains the number of voices reserved by the player
  741.      for the real channels and the virtual channels (NNA).
  742.  
  743.    - `numpas' and `numpat' contain the number of song positions and
  744.      song patterns.
  745.  
  746.    - `numins' and `numsmp' contain the number of instruments and
  747.      samples.
  748.  
  749.    - `songname' contains the song title.
  750.  
  751.    - `modtype' contains the name of the tracker used to create the song.
  752.  
  753.    - `comment' contains the song comment, if it has one.
  754.  
  755.    - `sngtime' contains the time elapsed in the module, in 2^-10
  756.      seconds (not exactly a millisecond).
  757.  
  758.    - `sngspd' and `bpm' contain the song speed and tempo.
  759.  
  760.    - `realchn' contains the actual number of active channels.
  761.  
  762.    - `totalchn' contains the actual number of active virtual channels,
  763.      i.e. the sum of `realchn' and the number of NNA virtual channels.
  764.  
  765.    Now that the module is loaded, you need to tell the module player
  766. that you want to play this particular module with `Player_Start' (the
  767. player can only play one module, but you can have several modules in
  768. memory). The playback begins. Should you forget which module is
  769. playing, `Player_GetModule' will return it to you.
  770.  
  771.    You can change the current song position with the functions
  772. `Player_NextPosition', `Player_PrevPosition' and `Player_SetPosition',
  773. the speed with `Player_SetSpeed' and `Player_SetTempo', and the volume
  774. (ranging from 0 to 128) with `Player_SetVolume'.
  775.  
  776.    Playback can be paused or resumed with `Player_TogglePause'. Be sure
  777. to check with `Player_Paused' that it isn't already in the state you
  778. want !
  779.  
  780.    Fine player control is achieved by the functions `Player_Mute',
  781. `Player_UnMute' and `Player_ToggleMute' which can silence or resume a
  782. set of module channels. The function `Player_Muted' will return the
  783. state of a given channel. And if you want even more control, you can
  784. get the voice corresponding to a module channel with
  785. `Player_GetChannelVoice' and act directly on the voice.
  786.  
  787.    Modules play only once, but can loop indefinitely if they are
  788. designed to do so.  You can change this behavior with the `wrap' and
  789. `loop' of the `MODULE' structure; the first one, if set, will make the
  790. module restart when it's finished, and the second one, if set, will
  791. prevent the module from jumping backwards.
  792.  
  793.    You can test if the module is still playing with `Player_Active',
  794. and you can stop it at any time with `Player_Stop'. When the module
  795. isn't needed anymore, get rid of it with `Player_Free'.
  796.  
  797. 
  798. File: mikmod.info,  Node: Loading Data from Memory,  Prev: Modules and Player Control,  Up: Using the Library
  799.  
  800. Loading Data from Memory
  801. ========================
  802.  
  803.    If you need to load modules or sound effects from other places than
  804. plain files, you can use the `MREADER' and `MWRITER' objects to achieve
  805. this.
  806.  
  807.    The `MREADER' and `MWRITER' structures contain a list of function
  808. pointers, which emulate the behaviour of a regular `FILE *' object. In
  809. fact, all functions which take filenames or `FILE *' as arguments are
  810. only wrappers to a real function which takes an `MREADER' or an
  811. `MWRITER' argument.
  812.  
  813.    So, if you need to load a module from memory, or for a multi-file
  814. archive, for example, all you need is to build an adequate `MREADER'
  815. object, and use `Player_LoadGeneric' instead of `Player_Load' or
  816. `Player_LoadFP'. For samples, use `Sample_LoadGeneric' instead of
  817. `Sample_Load' or `Sample_LoadFP'.
  818.  
  819. 
  820. File: mikmod.info,  Node: Library Reference,  Next: Index,  Prev: Using the Library,  Up: Top
  821.  
  822. Library Reference
  823. *****************
  824.  
  825.    This chapter describes in more detail all the functions and
  826. variables provided by the library. *Note Type Definitions::, for the
  827. basic type reference.
  828.  
  829. * Menu:
  830.  
  831. * Variable Reference::
  832. * Structure Reference::
  833. * Error Reference::
  834. * Function Reference::
  835. * Loader Reference::
  836. * Driver Reference::
  837.  
  838. 
  839. File: mikmod.info,  Node: Variable Reference,  Next: Structure Reference,  Prev: Library Reference,  Up: Library Reference
  840.  
  841. Variable Reference
  842. ==================
  843.  
  844. Error Variables
  845. ---------------
  846.  
  847.    The following variables are set by the library to return error
  848. information.
  849.  
  850. `int MikMod_errno'
  851.      When an error occurs, this variable contains the error code.
  852.      *Note Error Reference::, for more information.
  853.  
  854. `BOOL MikMod_critical'
  855.      When an error occurs, this variable informs of the severity of the
  856.      error. Its value has sense only if the value of `MikMod_errno' is
  857.      different from zero.  If the value of `MikMod_critical' is zero,
  858.      the error wasn't fatal and the library is in a stable state.
  859.      However, if it is nonzero, then the library can't be used and has
  860.      reseted itself to the uninitialized state. This often means that
  861.      the mixing parameters you choose were not supported by the driver,
  862.      or that it doesn't has enough voices for your needs if you called
  863.      `MikMod_SetNumVoices'.
  864.  
  865. Sound Settings
  866. --------------
  867.  
  868.    The following variables control the sound output parameters and
  869. their changes take effect immediately.
  870.  
  871. `UBYTE md_musicvolume'
  872.      Volume of the module. Allowed values range from 0 to 128. The
  873.      default value is 128.
  874.  
  875. `UBYTE md_pansep'
  876.      Stereo channels separation. Allowed values range from 0 (no
  877.      separation, thus mono sound) to 128 (full channel separation). The
  878.      default value is 128.
  879.  
  880. `UBYTE md_reverb'
  881.      Amount of sound reverberation. Allowed values range from 0 (no
  882.      reverberation) to 15 (a rough estimate for chaos...). The default
  883.      value is 6.
  884.  
  885. `UBYTE md_sndfxvolume'
  886.      Volume of the sound effects. Allowed values range from 0 to 128.
  887.      The default value is 128.
  888.  
  889. `UBYTE md_volume'
  890.      Overall sound volume. Allowed values range from 0 to 128. The
  891.      default value is 96.
  892.  
  893. Driver Settings
  894. ---------------
  895.  
  896.    The following variables control more in-depth sound output
  897. parameters. Except for some `md_mode' flags, their changes do not have
  898. any effect until you call `MikMod_Init' or `MikMod_Reset'.
  899.  
  900. `UWORD md_device'
  901.      This variable contains the order, in the list of the registered
  902.      drivers, of the sound driver which will be used for sound
  903.      playback. This order is one-based; if this variable is set to
  904.      zero, the driver is autodetected, which means the list is tested
  905.      until a driver is present on the system. The default value is 0,
  906.      thus driver is autodetected.
  907.  
  908. `MDRIVER* md_driver'
  909.      This variable points to the driver which is being used for sound
  910.      playback, and is undefined when the library is uninitialized
  911.      (before `MikMod_Init' and after `MikMod_Exit'). This variable is
  912.      for information only, you should never attempt to change its
  913.      value. Use `md_driver' and `MikMod_Init' (or `MikMod_Reset')
  914.      instead.
  915.  
  916. `UWORD md_mixfreq'
  917.      Sound playback frequency, in hertz. High values yield high sound
  918.      quality, but need more computing power than lower values. The
  919.      default value is 44100 Hz, which is compact disc quality. Other
  920.      common values are 22100 Hz (radio quality), 11025 Hz (phone
  921.      quality), and 8000 Hz (mu-law quality).
  922.  
  923. `UWORD md_mode'
  924.      This variable is a combination of several flags, to select which
  925.      output mode to select.  The following flags have a direct action
  926.      to the sound output (i.e. changes take effect immediately):
  927.     `DMODE_INTERP'
  928.           This flag, if set, enables the interpolated mixers.
  929.           Interpolated mixing gives better sound but takes a bit more
  930.           time than standard mixing. If the library is built with the
  931.           high quality mixer, interpolated mixing is always enabled,
  932.           regardless of this flag.
  933.  
  934.     `DMODE_REVERSE'
  935.           This flag, if set, exchanges the left and right stereo
  936.           channels.
  937.  
  938.     `DMODE_SURROUND'
  939.           This flag, if set, enables the surround mixers. Since
  940.           surround mixing works only for stereo sound, this flag has no
  941.           effect if the sound playback is in mono.
  942.  
  943.      The following flags aren't taken in account until the sound driver
  944.      is changed or reset:
  945.     `DMODE_16BIT'
  946.           This flag, if set, selects 16 bit sound mode. This mode
  947.           yields better sound quality, but needs twice more mixing time.
  948.  
  949.     `DMODE_HQMIXER'
  950.           This flag, if set, selects the high-quality software mixer.
  951.           This mode yields better sound quality, but needs more mixing
  952.           time. Of course, this flag has no effect if no
  953.           `DMODE_SOFT_xx' flag is set.
  954.  
  955.     `DMODE_SOFT_MUSIC'
  956.           This flag, if set, selects software mixing of the module.
  957.  
  958.     `DMODE_SOFT_SNDFX'
  959.           This flag, if set, selects software mixing of the sound
  960.           effects.
  961.  
  962.     `DMODE_STEREO'
  963.           This flag, if set, selects stereo sound.
  964.  
  965.      The default value of this variable is `DMODE_STEREO |
  966.      DMODE_SURROUND | DMODE_16BITS | DMODE_SOFT_MUSIC |
  967.      DMODE_SOFT_SNDFX'.
  968.  
  969. 
  970. File: mikmod.info,  Node: Structure Reference,  Next: Error Reference,  Prev: Variable Reference,  Up: Library Reference
  971.  
  972. Structure Reference
  973. ===================
  974.  
  975.    Only the useful fields are described here; if a structure field is
  976. not described, you must assume that it's an internal field which must
  977. not be modified.
  978.  
  979. Drivers
  980. -------
  981.  
  982.    The `MDRIVER' structure is not meant to be used by anything else
  983. than the core of the library, but its first four fields contain useful
  984. information for your programs:
  985. `CHAR* Name'
  986.      Name of the driver, usually never more than 20 characters.
  987.  
  988. `CHAR* Description'
  989.      Description of the driver, usually never more than 50 characters.
  990.  
  991. `UBYTE HardVoiceLimit'
  992.      Maximum number of hardware voices for this driver, 0 if the driver
  993.      has no hardware mixing support.
  994.  
  995. `UBYTE SoftVoiceLimit'
  996.      Maximum number of software voices for this driver, 0 if the driver
  997.      has no software mixing support.
  998.  
  999. `CHAR* Alias'
  1000.      A short name for the driver, without spaces, usually never more
  1001.      than 10 characters.
  1002.  
  1003. Modules
  1004. -------
  1005.  
  1006.    The `MODULE' structure gathers all the necessary information needed
  1007. to play a module file, regardless of its initial format.
  1008.  
  1009. General Module Information
  1010. ..........................
  1011.  
  1012.    The fields described in this section contain general information
  1013. about the module and should not be modified.
  1014.  
  1015. `CHAR* songname'
  1016.      Name of the module.
  1017.  
  1018. `CHAR* modtype'
  1019.      Type of the module (which tracker format).
  1020.  
  1021. `CHAR* comment'
  1022.      Either the module comments, or NULL if the module doesn't have
  1023.      comments.
  1024.  
  1025. `UWORD flags'
  1026.      Several module flags or'ed together.
  1027.     `UF_ARPMEM'
  1028.           If set, arpeggio effects have memory.
  1029.  
  1030.     `UF_BGSLIDES'
  1031.           If set, volume slide effects continue until a new note or a
  1032.           new effect is played.
  1033.  
  1034.     `UF_HIGHBPM'
  1035.           If set, the module is allowed to have its tempo value (bpm)
  1036.           over 255.
  1037.  
  1038.     `UF_INST'
  1039.           If set, the module has instruments and samples; otherwise, the
  1040.           module has only samples.
  1041.  
  1042.     `UF_LINEAR'
  1043.           If set, slide periods are linear; otherwise, they are
  1044.           logarithmic.
  1045.  
  1046.     `UF_NNA'
  1047.           If set, module uses new note actions (NNA) and the
  1048.           `numvoices' field is valid.
  1049.  
  1050.     `UF_NOWRAP'
  1051.           If set, pattern break on the last pattern does not continue
  1052.           to the first pattern.
  1053.  
  1054.     `UF_S3MSLIDES'
  1055.           If set, module uses old-S3M style volume slides (slides
  1056.           processed every tick); otherwise, it uses the standard style
  1057.           (slides processed every tick except the first).
  1058.  
  1059.     `UF_XMPERIODS'
  1060.           If set, module uses XM-type periods; otherwise, it uses Amiga
  1061.           periods.
  1062.  
  1063.     `UF_FT2QUIRKS'
  1064.           If set, module player will reproduce some FastTracker 2
  1065.           quirks during playback.
  1066.  
  1067. `UBYTE numchn'
  1068.      The number of channels in the module.
  1069.  
  1070. `UBYTE numvoices'
  1071.      If the module uses NNA, and this variable is not zero, it contains
  1072.      the limit of module voices; otherwise, the limit is set to the
  1073.      `maxchan' parameter of the `Player_Loadxx' functions.
  1074.  
  1075. `UWORD numpos'
  1076.      The number of sound positions in the module.
  1077.  
  1078. `UWORD numpat'
  1079.      The number of patterns.
  1080.  
  1081. `UWORD numins'
  1082.      The number of instruments.
  1083.  
  1084. `UWORD numsmp'
  1085.      The number of samples.
  1086.  
  1087. `INSTRUMENT* instruments'
  1088.      Points to an array of instrument structures.
  1089.  
  1090. `SAMPLE* samples'
  1091.      Points to an array of sample structures.
  1092.  
  1093. `UBYTE realchn'
  1094.      During playback, this variable contains the number of active
  1095.      channels (not counting NNA channels).
  1096.  
  1097. `UBYTE totalchn'
  1098.      During playback, this variable contains the total number of
  1099.      channels (including NNA channels).
  1100.  
  1101. `ULONG sngtime'
  1102.      Elapsed song time, in 2^-10 seconds units (not exactly a
  1103.      millisecond). To convert this value to seconds, divide by 1024,
  1104.      not 1000 !
  1105.  
  1106. Playback Settings
  1107. .................
  1108.  
  1109.    The fields described here control the module playback and can be
  1110. modified at any time, unless otherwise specified.
  1111.  
  1112. `UBYTE initspeed'
  1113.      The initial speed of the module (Protracker compatible). Valid
  1114.      range is 1-32.
  1115.  
  1116. `UBYTE inittempo'
  1117.      The initial tempo of the module (Protracker compatible). Valid
  1118.      range is 32-255.
  1119.  
  1120. `UBYTE initvolume'
  1121.      The initial overall volume of the module. Valid range is 0-128.
  1122.  
  1123. `UWORD panning[]'
  1124.      The current channel panning positions. Only the first `numchn'
  1125.      values are defined.
  1126.  
  1127. `UBYTE chanvol[]'
  1128.      The current channel volumes. Only the first `numchn' values are
  1129.      defined.
  1130.  
  1131. `UWORD bpm'
  1132.      The current tempo of the module. Use `Player_SetTempo' to change
  1133.      its value.
  1134.  
  1135. `UBYTE sngspd'
  1136.      The current speed of the module. Use `Player_SetSpeed' to change
  1137.      its value.
  1138.  
  1139. `UBYTE volume'
  1140.      The current overall volume of the module, in range 0-128. Use
  1141.      `Player_SetVolume' to change its value.
  1142.  
  1143. `BOOL extspd'
  1144.      If zero, Protracker extended speed effect (in-module tempo
  1145.      modification) is not processed. The default value is 1, which
  1146.      causes this effect to be processed.  However, some old modules
  1147.      might not play correctly if this effect is not neutralized.
  1148.  
  1149. `BOOL panflag'
  1150.      If zero, panning effects are not processed. The default value is
  1151.      1, which cause all panning effects to be processed. However, some
  1152.      old modules might not play correctly if panning is not neutralized.
  1153.  
  1154. `BOOL wrap'
  1155.      If nonzero, module wraps to its restart position when it is
  1156.      finished, to play continuously. Default value is zero (play only
  1157.      once).
  1158.  
  1159. `UBYTE reppos'
  1160.      The restart position of the module, when it wraps.
  1161.  
  1162. `BOOL loop'
  1163.      If nonzero, all in-module loops are processed; otherwise, backward
  1164.      loops which decrease the current position are not processed (i.e.
  1165.      only forward loops, and backward loops in the same pattern, are
  1166.      processed). This ensures that the module never loops endlessly.
  1167.      The default value is 1 (all loops are processed).
  1168.  
  1169. `BOOL fadeout'
  1170.      If nonzero, volume fades out during when last position of the
  1171.      module is being played. Default value us zero (no fadeout).
  1172.  
  1173. `UWORD patpos'
  1174.      Current position (row) in the pattern being played. Must not be
  1175.      changed.
  1176.  
  1177. `SWORD sngpos'
  1178.      Current song position. Do not change this variable directly, use
  1179.      `Player_NextPosition', `Player_PrevPosition' or
  1180.      `Player_SetPosition' instead.
  1181.  
  1182. `SWORD relspd'
  1183.      Relative playback speed. The value of this variable is added to
  1184.      the module tempo to define the actual playback speed. The default
  1185.      value is 0, which make modules play at their intended speed.
  1186.  
  1187. Module Instruments
  1188. ------------------
  1189.  
  1190.    Although the `INSTRUMENT' structure is intended for internal use, you
  1191. might need to know its name:
  1192.  
  1193. `CHAR* insname'
  1194.      The instrument text, theoretically its name, but often a message
  1195.      line.
  1196.  
  1197. Samples
  1198. -------
  1199.  
  1200.    The `SAMPLE' structure is used for sound effects and module samples
  1201. as well. You can play with the following fields:
  1202.  
  1203. `SWORD panning'
  1204.      Panning value of the sample. Valid values range from PAN_LEFT (0)
  1205.      to PAN_RIGHT (255), or PAN_SURROUND.
  1206.  
  1207. `ULONG speed'
  1208.      Playing frequency of the sample, it hertz.
  1209.  
  1210. `UBYTE volume'
  1211.      Sample volume. Valid range is 0-64.
  1212.  
  1213. `UWORD flags'
  1214.      Several format flags or'ed together describing the format of the
  1215.      sample in memory.
  1216.  
  1217.      Format flags:
  1218.     `SF_16BITS'
  1219.           If set, sample data is 16 bit wide; otherwise, it is 8 bit
  1220.           wide.
  1221.  
  1222.     `SF_BIG_ENDIAN'
  1223.           If set, sample data is in big-endian (Motorola) format;
  1224.           otherwise, it is in little-endian (Intel) format.
  1225.  
  1226.     `SF_DELTA'
  1227.           If set, sample is stored as delta values (differences between
  1228.           two consecutive samples); otherwise, sample is stored as
  1229.           sample values.
  1230.  
  1231.     `SF_ITPACKED'
  1232.           If set, sample data is packed with Impulse Tracker's
  1233.           compression method; otherwise, sample is not packed.
  1234.  
  1235.     `SF_SIGNED'
  1236.           If set, sample data is made of signed values; otherwise, it
  1237.           is made of unsigned values.
  1238.  
  1239.     `SF_STEREO'
  1240.           If set, sample data is stereo (two channels); otherwise, it
  1241.           is mono.
  1242.  
  1243.      Playback flags:
  1244.     `SF_BIDI'
  1245.           If set, sample loops "ping pong" (back and forth).
  1246.  
  1247.     `SF_LOOP'
  1248.           If set, sample loops forward.
  1249.  
  1250.     `SF_REVERSE'
  1251.           If set, sample plays backwards.
  1252.  
  1253. `UWORD inflags'
  1254.      Same as "flags", but describing the format of the sample on disk.
  1255.  
  1256. `ULONG length'
  1257.      Length of the sample, in _samples_. The length of a sample is 8
  1258.      bits (1 byte) for a 8 bit sample, and 16 bits (2 bytes) for a 16
  1259.      bit sample.
  1260.  
  1261. `ULONG loopstart'
  1262.      Loop starting position, relative to the start of the sample, in
  1263.      samples.
  1264.  
  1265. `ULONG loopend'
  1266.      Loop ending position, relative to the start of the sample, in
  1267.      samples.
  1268.  
  1269. MREADER
  1270. -------
  1271.  
  1272.    The `MREADER' contains the following function pointers:
  1273.  
  1274. `BOOL (*Seek)(struct MREADER*, long offset, int whence)'
  1275.      This function should have the same behaviour as `fseek', with
  1276.      offset 0 meaning the start of the object (module, sample) being
  1277.      loaded.
  1278.  
  1279. `long (*Tell)(struct MREADER*)'
  1280.      This function should have the same behaviour as `ftell', with
  1281.      offset 0 meaning the start of the object being loaded.
  1282.  
  1283. `BOOL (*Read)(struct MREADER*, void *dest, size_t length)'
  1284.      This function should copy `length' bytes of data into `dest', and
  1285.      return zero if an error occured, and any nonzero value otherwise.
  1286.      Note that an end-of-file condition will not be considered as an
  1287.      error in this case.
  1288.  
  1289. `int (*Get)(struct MREADER*)'
  1290.      This function should have the same behaviour as `fgetc'.
  1291.  
  1292. `BOOL (*Eof)(struct MREADER*)'
  1293.      This function should have the same behaviour as `feof'.
  1294.  
  1295.    For an example of how to build an `MREADER' object, please refer to
  1296. the `MFILEREADER' object in file `mmio/mmio.c' in the library sources.
  1297.  
  1298. MWRITER
  1299. -------
  1300.  
  1301.    The `MREADER' contains the following function pointers:
  1302.  
  1303. `BOOL (*Seek)(struct MWRITER*, long offset, int whence);'
  1304.      This function should have the same behaviour as `fseek', with
  1305.      offset 0 meaning the start of the object being written.
  1306.  
  1307. `long (*Tell)(struct MWRITER*);'
  1308.      This function should have the same behaviour as `ftell', with
  1309.      offset 0 meaning the start of the object being written.
  1310.  
  1311. `BOOL (*Write)(struct MWRITER*, void *dest, size_t length);'
  1312.      This function should copy `length' bytes of data from `dest', and
  1313.      return zero if an error occured, and any nonzero value otherwise.
  1314.  
  1315. `BOOL (*Put)(struct MWRITER*, int data);'
  1316.      This function should have the same behaviour as `fputc'.
  1317.  
  1318.    For an example of how to build an `MWRITER' object, please refer to
  1319. the `MFILEWRITER' object in file `mmio/mmio.c' in the library sources.
  1320.  
  1321.